#ifndef XML_PARSER_H
#define XML_PARSER_H

// using libxml2 for xml-parsing...
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

#include "parser.h"
#include "parse_exception.h"
#include "network.h"

#include "model/parser.h"
#include "model/dom_policy.h"
#include "model/dom.h"

#include <boost/shared_ptr.hpp>

#include <string>
#include <boost/regex.hpp>

using namespace std;

namespace network {
	class xml_parser : public network::parser {
	public:
		xml_parser():_buff(""), _start_tag(""), _end_in_start(false) {}
		virtual ~xml_parser() {}

		virtual boost::shared_ptr<model::dom> parse(
			const string &msg);
	private:
		boost::shared_ptr<model::dom> convert(xmlDocPtr ptr);
		void recur_conv(xmlNode *ptr, boost::shared_ptr<model::dom>);
		void conv_attrib(xmlAttr *attr, 
			boost::shared_ptr<model::dom>);
	
		string _buff;
		string _start_tag;
		bool _end_in_start;
	};
}

#endif
